package com.daiqile.rxjava;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

/**
 * @author Mr.Bean
 * @date Created on 2017/8/30.
 */

public class RecycleAdapter extends RecyclerView.Adapter<RecycleAdapter.ViewHolder>{
    private List<Somethings>  somethingsList;
    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView textView ;
        public ViewHolder(View view){
            super(view);
            textView = (TextView)view.findViewById(R.id.tp);
        }

    }
    public RecycleAdapter(List<Somethings> somethingses){
        somethingsList = somethingses;

    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardviewitem,parent,false);
        RecycleAdapter.ViewHolder viewHolder = new RecycleAdapter.ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        Somethings somethings = somethingsList.get(position);
        holder.textView.setText(somethings.getXx());
    }

    @Override
    public int getItemCount() {
        return somethingsList.size();
    }
}
